package com.it.spider;

import com.it.SchoolTemp;
import com.it.domain.Bd_school;
import com.it.domain.School;
import com.it.utils.MyBatisUtil;

import org.apache.ibatis.session.SqlSession;
import org.junit.Test;


import java.sql.ResultSet;
import java.util.List;

/**
 * Created by Administrator on 2015/12/21.
 */
public class schoolMatch {

     @Test
    //表中是否存在该学校,若存在，则不用插入，若不存在，则插入
    public void schoolIsExtist(){

        //拿出shool表中所有的学校 name ，area，
        //select name,area from bd_school;保存到list中；
        SqlSession sqlSession = MyBatisUtil.getSqlSession(true);
       SchoolTemp school=null;
       // sqlSession.select("select name,area from bd_school where area is not null and name is not null");

        String state ="com.it.mapping.bd_schoolMapper.getAllSchool";
        List<Bd_school> schoolList = sqlSession.selectList(state);
        System.out.println(schoolList.size());
        for(Bd_school bd_school : schoolList){
            String name=bd_school.getName();
           String area= bd_school.getAddress();
            String area1 =null;
            int i=0;
            if( name.indexOf("区")>0) {
                i=name.indexOf("区");
                 area1=name.substring(i+1 ,name.length());
                System.out.println(area1);
            }
            else if(name.indexOf("市")>0){
                i=name.indexOf("市");
                area1=name.substring(i+1 ,name.length());
                System.out.println(area1);

            }else{
                System.out.println(name);
            }

            if(name.indexOf("县")>0){
                i=name.indexOf("县");
                area1=name.substring(i+1 ,name.length());

            }

        }




       // return  false;

    }




}
